1. Field of the Invention
The present invention relates to a method and apparatus for inter prediction encoding/decoding an image, and more particularly, to a method and apparatus for performing inter prediction by using a high precision sub-pixel, and encoding/decoding an image based on the result of inter prediction.
2. Description of the Related Art
In conventional methods of compressing an image, such as MPEG-1, MPEG-2, and MPEG-4H.264/MPEG-4 advanced video coding (AVC), a picture is divided into macro blocks in order to encode an image. Then, each macro block is encoded using inter prediction or intra prediction.
In methods of encoding an image by using inter prediction, the image is compressed by removing temporal redundancies among pictures, and a representative example of such methods is a motion estimation-based encoding method in which each motion of blocks included in a current picture is estimated by using at least one reference picture. Here, a reference block most similar to the current block is searched for within a predetermined search range of the at least one reference picture, using a predetermined evaluation function.
A sum of absolute difference (SAD) between a current block and a block included in a reference picture is calculated, and a block with the least SAD is determined as a reference block of the current block, and the determined reference block is a prediction block of the current block. A residual block of the current block is generated by subtracting the prediction block from the current block, and the compression rate of image encoding is increased by only encoding the generated residual block. A unit of a block that is encoded can be in various sizes, such as 16×16, 8×16, 16×8, 8×8, and 4×4 pixels.
Since only the residual block is encoded, the more accurate the prediction block is, and the more efficiently the current block can be compressed. Accordingly, if the reference block most similar to the current block can be found, the current block can be encoded with a high compression rate.
Hence according to H.264/AVC, sub-pixels in a pixel unit smaller than an integer pel unit are generated by performing interpolation on the reference picture, and then high precision motion estimation is performed based on the generated sub-pixels, as will be described in detail with reference to FIG. 1.
FIG. 1 is a diagram for describing a conventional method of performing interpolation.
Referring to FIG. 1, interpolation is performed by using a 6-tap finite impulse response (FIR) filter so as to generate sub-pixels a through 1 in a half pel unit. Looking at vertical ½ sub-pixels a through f, the sub-pixel a is generated by performing the interpolation by using A1, A2, A3, A4, A5, and A6, and the sub-pixel b is generated by performing the interpolation by using B1, B2, B3, B4, B5, and B6. The sub-pixels c, d, e, and f are generated in the same manner.
Pixel values of the vertical ½ sub-pixels a through f are calculated as, for example, a=(A1−5×A2+20×A3+20×A4−5×A5+A6)/32, and b=(B1−5×B2+20×B3+20×B4−5×B5+B6)/32. Pixel values of the vertical ½ sub-pixels c through f are calculated in the same manner.
Like the vertical ½ sub-pixels a through f, horizontal ½ sub-pixels g through 1 are generated by performing interpolation using the 6-tap FIR filter. A sub-pixel g is generated by using A1, B1, C1, D1, E1, and F1, and a sub-pixel h is generated by using A2, B2, C2, D2, E2, and F2.
Pixel values of the horizontal sub-pixels can be calculated in the same manner as the pixel values of the vertical ½ sub-pixels a through f. For example, g=(A1−5×B1+20×C1+20×D1−5×E1+F1)/32.
The diagonal sub-pixel m in a half pel unit is interpolated by using another sub-pixel in a half pel unit. In other words, a pixel value of the sub-pixel m can be calculated by using an equation m=(a−5×b+20×c+20×d−5×e+/32.
When the sub-pixels in a half pel unit are generated, sub-pixels in a quarter pel unit can be generated by using the pixels in an integer pel unit and the sub-pixels in a half pel unit. The sub-pixels in a quarter pel unit are generated by performing linear interpolation on its two adjacent pixels.
For example, a sub-pixel n in a quarter pel unit is generated by performing linear interpolation on a pixel C3 in an integer pel unit and the sub-pixel c in a half pel unit. In other words, a pixel value of the sub-pixel n is calculated by using an equation n=(C3+c)/2. Also, a sub-pixel o in a quarter pel unit is generated by performing linear interpolation on the sub-pixel c in a half pel unit and the sub-pixel m in a half pel unit. Accordingly, a pixel value of the sub-pixel o is calculated by using an equation o=(c+m)/2. A sub-pixel p in a quarter pel unit is interpolated by using diagonal linear interpolation. A pixel value of the sub-pixel p is calculated by using an equation p=(d+j)/2.
As illustrated in FIG. 1, when the sub-pixels in a half pel unit and a quarter pel unit are generated by performing interpolation on the reference picture, a block with the least SAD is searched for in a quarter pel unit by comparing the interpolated reference picture and the current block. Accordingly, a motion vector in a quarter pel unit is estimated.
More bits are used when encoding the motion vector in a quarter pel unit than a motion vector in an integer pel unit. However, accurate inter prediction can be performed in a quarter pel unit, and thus the number of bits used to encode a residual block can be reduced.
However, when sub-pixels are generated by performing interpolation in a pixel unit smaller than a quarter pel unit, such as one-eighth pel unit, and a motion vector is estimated in an one-eighth pel unit based on the generated sub-pixels, too many bits are used while encoding the motion vector, and thus the compression rate may deteriorate. Accordingly, a method and apparatus for efficiently encoding a motion vector in a small pel unit is required.